/*
 * main.cpp
 *
 *  Created on: Dec 15, 2013
 *      Author: justin
 */
//START

#include <iostream>
#include "pbStatements.h"
#include "morphologyOperations.h"
using namespace std;


int main(int argc, char** argv)
{
    IplImage *img=cvLoadImage("b.jpg", CV_LOAD_IMAGE_ANYCOLOR);
    CvMemStorage * storageOfChild = 0;
    CvSeq * childs = 0;
    morphologyOperations(img, childs, storageOfChild);
    for(int i=0;i<childs->total;i++) {
        childImg * child = *(childImg **)cvGetSeqElem(childs,i);
        char str[100];
        sprintf(str, "image%d", i);
        cvShowImage(str, child->chimg);
        cvMoveWindow(str, 50+(i%10)*50, 50+i/10*100 );
        cvResizeWindow(str, child->width, child->height+30);
        //cout<<child->x<<", "<<child->y<<endl;
    }
    for(int i=0;i<childs->total;i++) {
        delete *(childImg **)cvGetSeqElem(childs,i);
    }
    cvReleaseMemStorage(&storageOfChild);
    cvWaitKey(0);
    cvReleaseImage(&img);
    cvDestroyWindow("image");
    return 0;
}
